#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

void* new_thread(void* arg)
{
    while(1)
    {
          printf("%s,我所在的进程id是:%d\n",(char*)arg,getpid());//获取此线程所在进程的ID
              sleep(1);
                
    }

}

int main()
{
    pthread_t tid;//线程的ID
      pthread_create(&tid,NULL,new_thread,(void*)"我是新线程");
      pthread_create(&tid,NULL,new_thread,(void*)"我是新线程");

        while(1)
            { 
                printf("-----------------------------------------------------------\n");
                printf("我是主线程，我所在的进程的id是:%d\n",getpid());//获取主线程所在进程的ID
                sleep(1);
              }

}


